import book.Book;
import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;
import java.util.Scanner;
import operation.Operation;
public class Main {
    public static User login() {
        System.out.println("请输入用户名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        System.out.println("请选择登陆方式：");
        System.out.println("1.管理员   2. 普通用户");
        while (true) {
            int choice = sc.nextInt();
            if (choice == 1) {
                return new AdminUser(name);
            } else if (choice == 2) {
                return new NormalUser(name);
            } else {
                System.out.println("输入非法,请重新输入");
            }
        }
    }

    public static void main(String[] args) {
        BookList booklist = new BookList();//创建书架对象
        User user = login();//返回用户对象
        while (true) {
            int choice = user.menu();
            user.doOperation(choice,booklist);
        }

    }
}
